﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Timers;
using System.Threading;
using Cooperation.Layout;
using System.Net;

namespace Cooperation
{
    public partial class Login : Form
    {
        string username = string.Empty;
        string password = string.Empty;
        //Thread workThread = null;
        public static Login LoginForm { get; private set; }
        private Login(string username,string password)
        {
            InitializeComponent();
            this.username = username;
            this.password = password;
            this.SetBounds((Screen.GetBounds(this).Width / 2) - (this.Width / 2),
               (Screen.GetBounds(this).Height / 2) - (this.Height / 2),
               this.Width, this.Height, BoundsSpecified.Location);
            Window.AnimateWindow(Handle, 500, Window.AW_BLEND);
            LoginForm = this;
            //workThread = new Thread(delegate(object o)
            //{
                
            //});
            //workThread.IsBackground = true;
            //workThread.Start();
        }
        public bool DoLogin()
        {
            return new com.yaojianzhi.cooperation.Cooperation().Login(username, password);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //workThread.Abort();
            this.Close();
            Index.IndexForm.Visible = true;
        }
        public static void ShowLoginForm(string username, string password)
        {
            if (LoginForm == null)
            {
                new Login(username, password).Show();
            }
            else
            {
                LoginForm.Show();
            }
        }

        private void Login_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (LoginForm != null)
            {
                LoginForm = null;
            }
        }
    }
}
